﻿using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;

namespace SimpleEFTemplate
{
	internal class SqliteDBContext: DbContext
	{
		public DbSet<UserEntity> Users { get; set; }

		protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
		{
			string dbFile = Path.Combine(AppContext.BaseDirectory,"app.db");
			string conStr = $"Data Source={dbFile}";
			if (!File.Exists(dbFile))
			{
				File.Create(dbFile);
			}
			optionsBuilder.UseSqlite(conStr);
		}

		protected override void OnModelCreating(ModelBuilder modelBuilder)
		{
			modelBuilder.Entity<UserEntity>().ToTable("UserTable");
		}
	}
}
